package br.com.gbvbahia.mybooks;

import java.io.Serializable;

import android.os.Bundle;
import br.com.gbvbahia.mybooks.fragment.FragmentTransfer;
import br.com.gbvbahia.mybooks.fragment.ListarLivrosFragment;
import br.com.gbvbahia.mybooks.fragment.LivroCadastrarFragment;
import br.com.gbvbahia.mybooks.fragment.LivroCountFragment;
import br.com.gbvbahia.mybooks.modelos.LivroVO;

public class Cadastro extends ActivityMae implements FragmentTransfer {

	public static final String CADASTRO_RETURN = "cad_return";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.cadastro);
	}

	@Override
	public void updateFragment(int idFragmentToUpdate, Serializable obj) {
		switch (idFragmentToUpdate) {
		case R.layout.listar:
			LivroCadastrarFragment cadastro = (LivroCadastrarFragment) getSupportFragmentManager()
					.findFragmentByTag("cadastrofrag");
			cadastro.setLivro((LivroVO) obj);
			break;
		case R.layout.frag_cadastrar:
			ListarLivrosFragment frag = (ListarLivrosFragment) getSupportFragmentManager()
					.findFragmentByTag("fraglista");
			frag.startTransacao(frag);
			LivroCountFragment fragCount = (LivroCountFragment) getSupportFragmentManager()
					.findFragmentByTag("fragcount");
			fragCount.onResume();
			break;
		}
	}

}
